using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace SharpMud.Net
{
    /// <summary>
    /// Represents the state of a network connection's 'session's state, and what action needs to be performed
    /// on it when pulsed
    /// </summary>
    /// <remarks>The idea being, that session state's can be customized by being coded externally, then listed, stacked, queued, etc</remarks>
	public interface ISessionState : IDisposable
	{
        /// <summary>
        /// Initializes the ISessionState using the session that it will be the state of, and optionally, the parent state that 
        /// spawned it
        /// </summary>
        /// <param name="session">The session that this session state belongs to</param>
        /// <param name="parentState">The session state that spawned this one. May be null.</param>
        void Initialize(IHostedConnectionHandler session,ISessionState parentState);

        /// <summary>
        /// Tells the session state to perform its actions, or sets of actions, on its IHostedConnectionHandler
        /// </summary>
        void Pulse();

        /// <summary>
        /// The session state that spawned this one. May be null.
        /// </summary>
        ISessionState ParentState { get;}

        /// <summary>
        /// A string of letters and numbers, no spaces or symbols, representing what this session state is
        /// </summary>
        /// <remarks>A list of successive session states are designated by stringing together multiple StateID's, using periods as a delimiter</remarks>
        string StateID { get;}

        /// <summary>
        /// Indicates to the parent state whether or not this session state is still in use
        /// </summary>
        /// <remarks>
        /// As soon as the parent state detects that this property returns false, it should remove this session state and dispose of it
        /// </remarks>
        bool StillActive { get;}
	}

    /// <summary>
    /// A Generic version of ISessionState that is aware of the specific type of session object that 
    /// is being used. Represents the state of a network connection's 'session's state, and what action 
    /// needs to be performed on it when pulsed
    /// </summary>
    /// <typeparam name="TSession">The type of session that is being used</typeparam>
    public interface ISessionState<TSession> : ISessionState where TSession : IHasSessionState<TSession>
    {
        /// <summary>
        /// Initializes the ISessionState using the session that it will be the state of, and optionally, the parent state that 
        /// spawned it
        /// </summary>
        /// <param name="session">The session that this session state belongs to</param>
        /// <param name="parentState">The session state that spawned this one. May be null.</param>
        void Initialize(TSession session,ISessionState<TSession> parentState);

        /// <summary>
        /// The session state that spawned this one. May be null.
        /// </summary>
        ISessionState<TSession> ParentState { get;}
    }
}
